<link rel="stylesheet" type="text/css" href="<?php echo TEMPLATES_PATH;?>/css/activity.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo TEMPLATES_PATH;?>/css/search_html5.css"/>		
<script src="<?php echo TEMPLATES_PATH;?>/js/screening.js"></script>
<script type="text/javascript">
var tms = [];
 var day = [];
 var hour = [];
 var minute = [];
 var second = [];
function takeCount() {
    setTimeout("takeCount()", 1000);
    for (var i = 0, j = tms.length; i < j; i++) {
        tms[i] -= 1;
        //计算天、时、分、秒、
        var days = Math.floor(tms[i] / (1 * 60 * 60 * 24));
        var hours = Math.floor(tms[i] / (1 * 60 * 60)) % 24;
        var minutes = Math.floor(tms[i] / (1 * 60)) % 60;
        var seconds = Math.floor(tms[i] / 1) % 60;
        if (days < 0)
            days = 0;
        if (hours < 0)
            hours = 0;
        if (minutes < 0)
            minutes = 0;
        if (seconds < 0)
            seconds = 0;
        //将天、时、分、秒插入到html中
        document.getElementById(day[i]).innerHTML = days;
        document.getElementById(hour[i]).innerHTML = hours;
        document.getElementById(minute[i]).innerHTML = minutes;
        document.getElementById(second[i]).innerHTML = seconds;
    }
}
setTimeout("takeCount()", 1000);

//提交查询
function submit_search() {
        $('#search_form').attr('method','get');
         pclicked('index.php?'+$('#search_form').serialize());
}
//团购地区筛选
function set_groupbuy_area(obj) {
    $(obj).addClass('on').siblings().removeClass('on');
	$('#groupbuy_area').val($(obj).attr('data'));
    submit_search();
}
//团购分类筛选
function set_groupbuy_class(obj) {
    $(obj).addClass('on').siblings().removeClass('on');
	$('#groupbuy_class').val($(obj).attr('data'));
    submit_search();
}
//团购价格筛选
function set_groupbuy_price(obj) {
   $(obj).addClass('on').siblings().removeClass('on');
	$('#groupbuy_price').val($(obj).attr('data'));
    submit_search();
} 
//排序
function changeOrder(obj){
	var key = $('#groupbuy_order_key');
	var order = $('#groupbuy_order');
	if($(obj).data('tp') == key.val()){
		if($(obj).data('tp') == 'default'){
			order.val('');
		}else if(order.val() == 'desc'){
			order.val('asc');
		}else {
			order.val('desc');
		}
	}else{
		key.val($(obj).data('tp'));
		
		if($(obj).data('tp') == 'default'){
			order.val('');
		}else{
			order.val('desc');
		}
	}
	 submit_search();
}
</script>
<header class="layout head padding-small">
    <a href="javascript:back(true);" class="hBack float-left"></a>
    <h4 class="hTxt float-left text-center text-white">团购专区</h4>
    <a href="javascript:;" id="btnJdkey" class="hHlep float-right"></a>
</header>

<div style="position: absolute; width: 190px; height: 792px; right: 0px; top: -28px; z-index: 20001; overflow: hidden; -webkit-transform-origin: 0px 0px; opacity: 1; -webkit-transform: scale(1, 1); display: none;" id="filterbar">
	<div class="new-tab-type">
    	<div class="new-srch-pop" id="slidebar" style="-webkit-transition: -webkit-transform 0.4s;-webkit-transform-origin: 0px 0px; -webkit-transform-style: preserve-3d;-webkit-transform: translate(190px, 0);">
        	<div class="new-pop-ul new-p-re" id="filter_prop">
                <ul class="new-ul-lst">
                
                    <li class="new-ul-li">
                        <a href="javascript:void(0)" onclick="showHideFilter(this)" class="new-li-a on">团购分类</a>
                        <div class="new-pop-sel" style="-webkit-transform-origin: 0px 0px; opacity: 1; -webkit-transform: scale(1, 1); display:none;">
                            <ul>
                                <li><a href="javascript:void(0)" onclick="set_groupbuy_class(this)" data="0" class="<?php echo (int)$_GET['groupbuy_class'] ==0 ? 'on':''?>"><span>全部</span></a></li>
                                <?php 
									if(!empty($output['class_list']) && is_array($output['class_list'])){ 
										foreach ($output['class_list'] as $k=>$v){;
								?>
                                <li><a href="javascript:void(0)" onclick="set_groupbuy_class(this)" data="<?php echo $v['class_id'];?>" class="<?php echo (int)$_GET['groupbuy_class'] == $v['class_id'] ? 'on':''?>"><span><?php echo $v['class_name'];?></span></a></li>
                                <?php }?>	
                                <?php }?>
                            </ul>
                        </div>
                    </li>
                    
                    <li class="new-ul-li">
                        <a href="javascript:void(0)" onclick="showHideFilter(this)" class="new-li-a on">团购区域</a>
                        <div class="new-pop-sel" style="-webkit-transform-origin: 0px 0px; opacity: 1; -webkit-transform: scale(1, 1); display:none;">
                            <ul>
                                <li><a href="javascript:void(0)" onclick="set_groupbuy_area(this)" data="0"  class="<?php echo (int)$_GET['groupbuy_area'] ==0 ? 'on':''?>"><span>全部</span></a></li>
                                <?php 
									if(!empty($output['area_list']) && is_array($output['area_list'])){ 
										foreach ($output['area_list'] as $k=>$v){;
								?>
                                <li><a href="javascript:void(0)" onclick="set_groupbuy_area(this)" data="<?php echo $v['area_id'];?>" class="<?php echo (int)$_GET['groupbuy_area'] == $v['area_id'] ? 'on':''?>"><span><?php echo $v['area_name'];?></span></a></li>
                                <?php }?>	
                                <?php }?>
                            </ul>
                        </div>
                    </li>
                    
                    <li class="new-ul-li">
                        <a href="javascript:void(0)" onclick="showHideFilter(this)" class="new-li-a on">价格区间</a>
                        <div class="new-pop-sel" style="-webkit-transform-origin: 0px 0px; opacity: 1; -webkit-transform: scale(1, 1); display:none;">
                            <ul>
                                <li><a href="javascript:void(0)" onclick="set_groupbuy_price(this)" data="0" class="<?php echo (int)$_GET['groupbuy_price'] ==0 ? 'on':''?>"><span>全部</span></a></li>
                                <?php 
									if(!empty($output['price_list']) && is_array($output['price_list'])){ 
										foreach ($output['price_list'] as $k=>$v){;
								?>
                                <li><a href="javascript:void(0)" onclick="set_groupbuy_price(this)" data="<?php echo $v['range_id'];?>" class="<?php echo (int)$_GET['groupbuy_price'] == $v['range_id'] ? 'on':''?>"><span><?php echo $v['range_name'];?></span></a></li>
                                <?php }?>	
                                <?php }?>
                            </ul>
                        </div>
                    </li>

                </ul>
             </div>
    	</div>
	</div>
</div>

<form id="search_form">
  <input name="act" type="hidden" value="groupbuy" />
  <input name="op" type="hidden" value="groupbuy_list" />
  <input id="groupbuy_area" name="groupbuy_area" type="hidden" value="<?php echo $_GET['groupbuy_area'];?>"/>
  <input id="groupbuy_class" name="groupbuy_class" type="hidden" value="<?php echo $_GET['groupbuy_class'];?>"/>
  <input id="groupbuy_price" name="groupbuy_price" type="hidden" value="<?php echo $_GET['groupbuy_price'];?>"/>
  <input id="groupbuy_order_key" name="groupbuy_order_key" type="hidden" value="<?php echo $_GET['groupbuy_order_key'];?>"/>
  <input id="groupbuy_order" name="groupbuy_order" type="hidden" value="<?php echo $_GET['groupbuy_order'];?>"/>
</form>

<div class="_group">
	<div class="store_search_order">
        <a href="javascript:void(0)" onclick="changeOrder(this)" data-tp="default"><span <?php if($_GET['groupbuy_order_key']=='default' || $_GET['groupbuy_order_key'] == ''){ echo 'class="on"';}?>>默认</span></a>
        <a href="javascript:void(0)" onclick="changeOrder(this)" data-tp="sale"><span <?php if($_GET['groupbuy_order_key']=='sale'){ echo 'class="on"';}?>>销量<?php echo ($_GET['groupbuy_order']=='desc' && $_GET['groupbuy_order_key']=='sale')?'↑':(($_GET['groupbuy_order']=='asc' && $_GET['groupbuy_order_key']=='sale')?'↓':'')?></span></a>
        <a href="javascript:void(0)" onclick="changeOrder(this)" data-tp="price"><span <?php if($_GET['groupbuy_order_key']=='price'){ echo 'class="on"';}?>>价格<?php echo ($_GET['groupbuy_order']=='desc' && $_GET['groupbuy_order_key']=='price')?'↑':(($_GET['groupbuy_order']=='asc' && $_GET['groupbuy_order_key']=='price')?'↓':'')?></span></a>
        <a href="javascript:void(0)" onclick="changeOrder(this)" data-tp="rebate"><span <?php if($_GET['groupbuy_order_key']=='rebate'){ echo 'class="on"';}?>>折扣<?php echo ($_GET['groupbuy_order']=='desc' && $_GET['groupbuy_order_key']=='rebate')?'↑':(($_GET['groupbuy_order']=='asc' && $_GET['groupbuy_order_key']=='rebate')?'↓':'')?></span></a>
        <a href="javascript:void(0)" id="_group_sx" onclick="showFilter()"><span>筛选</span></a>
    </div>
    
    <?php  if(!empty($output['groupbuy_list']) && is_array($output['groupbuy_list'])){?>
    <div class="_group_list">
        <?php  foreach($output['groupbuy_list'] as $item){?>
        <a url="index.php?act=goods&goods_id=<?php echo $item['goods_id']?>" onClick="pclicked(this);">
            <img src="<?php echo SiteUrl.DS.ATTACH_GROUPBUY.DS.$item['group_pic']?>" alt="<?php echo $item['goods_name'];?>"  onerror="this.src='<?php echo TEMPLATES_PATH.'/images/touch2013/no_300_300.jpg'?>'" />
            <div class="_group_info">
                <span><?php echo $item['group_name']?><span class="_group_quan"><strong><?php echo $item['def_quantity']+$item['virtual_quantity'];?></strong>人已参团</span></span>
                <span>
                <?php if($_SESSION['is_login'] != 1){?>
                    登录后显示
                <?php }else{?>
                	<del>&yen;<?php echo $item['goods_price']?></del><span class="_group_price">&yen;<?php echo $item['group_price']?></span>
                <?php }?>
                </span>
            </div>
            <div class="_group_discount">
            	<span class="dis_num"><?php echo $item['rebate']?></span>
                <span class="dis_str">折</span>
            </div>
        </a>
        <?php }?>
    </div>
    <?php include 'page.php';?>
    <?php }else{?>
    <div style="font-size:1.5em; margin:20px 0; color:#F90; text-align:center;">暂无相关的数据记录</div>
    <?php }?>
</div>

<div class="_group_temp">
    <span id="d1">0</span><strong> 天</strong>
    <span id="h1">0</span><strong> 时</strong>
    <span id="m1">0</span><strong> 分</strong>
    <span id="s1">0</span><strong> 秒</strong>
</div>

<script language="JavaScript">
tms[tms.length] = "<?php echo $output['count_down'];?>";
day[day.length] = "d1";
hour[hour.length] = "h1";
minute[minute.length] = "m1";
second[second.length] = "s1";
</script>